<?php get_header(); ?>

<div id="colLeft">
<?
	if (have_posts())
	{
		the_post();
		
		global $wpdb;
		$res = $wpdb->get_results("	SELECT `meta_value`
									FROM $wpdb->postmeta
									WHERE `post_id` = ".$post->ID." AND `meta_key` = 'image' ORDER BY `meta_id` DESC");
		$thumb_image = array();
		foreach($res as $row)
		{
			 $thumb_image[] = $row->meta_value;
		}
	   
?>
<table id="jk_tb_ctsanpham">
<tr>

	<td rowspan="4" class="sp_image">
    	<div class="big_image">
        <a rel="pro_image" id="full_1" href="<?= $thumb_image[0]; ?>" title="<? the_title() ?>" ><img src="<?= $thumb_image[0]; ?>" alt="<? the_title() ?>" title="<? the_title() ?>" /></a>
        <a rel="pro_image" id="full_2" href="<?= $thumb_image[1]  ?>" title="<? the_title() ?>" style="display:none"><img src="<?= $thumb_image[1] ?>" alt="<? the_title() ?>" title="<? the_title() ?>" /></a>
        <a rel="pro_image" id="full_3" href="<?= $thumb_image[2]  ?>" title="<? the_title() ?>" style="display:none"><img src="<?= $thumb_image[2] ?>" alt="<? the_title() ?>" title="<? the_title() ?>" /></a>
        </div>
        <div class="thumb_image">
        	<table id="tb_thumb">
            	<tr>
                    <td><a id="thumb_1" title="" onmouseover="changepicture(1)">
                    		<img src="<?= $thumb_image[0]  ?>" alt="<? the_title() ?>" title="<? the_title() ?>" />
                    	</a>
                    </td>
                    <? if($thumb_image[1] != ''){ ?>
                    <td><a id="thumb_2" title="" onmouseover="changepicture(2)">
                    		<img src="<?= $thumb_image[1]  ?>" alt="<? the_title() ?>" title="<? the_title() ?>" />
                    	</a>
                    </td>
                    <? } 
					   if($thumb_image[2] != ''){ ?>
                    <td><a id="thumb_3" title="" onmouseover="changepicture(3)">
                    		<img src="<?= $thumb_image[2]  ?>" alt="<? the_title() ?>" title="<? the_title() ?>" />
                    	</a>
                    </td>
                    <? } ?>
                </tr>                
            </table>
        </div>
    </td>
    <td rowspan="4" width="3%"></td>
    <td class="sp_title"><h1><? the_title() ?></h1></td>	
</tr>
<tr>
    <td class="sp_price">
   		<p class="price">Giá: <? $gia = (int)get_post_meta($post->ID,'giaban',true) - (int)get_post_meta($post->ID,'giamgia',true);
								 if($gia != 0)
								 	echo format_number($gia,0).' VND <i> (Giá đã bao gồm VAT)</i>';
								 else echo 'Liên hệ';
								?></p>
    <?
		if(get_post_meta($post->ID,'giamgia',true) != '')
		{		
	?>
        <p class="price_old">Giá thị trường: <span style="text-decoration:line-through"><?= format_number(get_post_meta($post->ID,'giaban',true),0) ?> VND</span></p>
        <p class="price_discount">Giảm giá: <?= format_number(get_post_meta($post->ID,'giamgia',true),0)?> VND</p>  
    <?
		}
	?>		
    </td>
    	
</tr>
<tr>
	<td class="sp_checkout">
    	<form name="frm_addcart" action="" method="post">
    	<div class="sp_qty">
        Số lượng: <input type="text" name="product_qty_onl" size="2" maxlength="2" value="1"/>
        </div>
        <div class="div_mua">
        <input type="submit" class="btn_mua" value="" />
       	</div>
        </form>
    </td>
</tr>
<tr>
    <td class="jktd_download">
    	<div id="sp_download">
        	<ul>
            	<li class="dl_document"><a href="#" title="Tải tài liệu">Tải tài liệu</a></li>
                <li class="dl_driver"><a href="#" title="Tải Driver">Tải Driver</li>
            </ul>
        </div>
    </td>
</tr>
</table>
<div id="product_info">
    <div id="tabContaier">
        <ul>
            <li><a title="1" class="active">Tính năng</a></li>
            <li><a title="2">Thông số kỹ thuật</a></li>
            <li><a title="3">Nhận xét</a></li>
        </ul>
    </div>
    <div id="tabDetails">
            <div id="1" class="tabContents">
                <? the_content();  ?>
            </div>
            <div id="2" class="tabContents">
               <? if(get_post_meta($post->ID,'thongsokythuat',true) != ''){
			   		echo get_post_meta($post->ID,'thongsokythuat',true);
			   		}
				  else
				  	echo 'Thông tin đang được cập nhật';
				?>
            </div>
            <div id="3" class="tabContents">
                <?php comments_template(); ?>
            </div>
    </div>
</div>
<?php
	}
	else
	{
?>
		<p class="jk_err">Hàng đã hết. Trở về trang <a href="<? bloginfo('url'); ?>"><? bloginfo('name'); ?></a></p>
<?php	
    }
?>
</div>
<?php get_sidebar(); ?>	
<?php get_footer(); ?>